jQuery(function($){
	var swiper1 = new Swiper('.tab-nav', {
        slidesPerView: 5,
        freeMode : true,
        freeModeMomentumRatio: 0.5,
        observer:true,
        observeParents:true
    })
    
    swiper1.container.on("click", function(){

        var slide = swiper1.slides.eq(swiper1.clickedIndex);
        
        slide.addClass("active").siblings().removeClass("active");

        var swiperHalf = swiper1.width / 2;
        var maxTranslate = swiper1.maxTranslate();
        var maxWidth = -maxTranslate + swiperHalf;

        var slideLeft = slide[0].offsetLeft;
        var slideWidth = slide[0].clientWidth;
        var slideCenter = slideLeft + slideWidth / 2;
        // 被点击slide的中心点

        swiper1.setWrapperTransition(300)

        if (slideCenter < swiperHalf) {
            swiper1.setWrapperTranslate(0);
        } else if (slideCenter > maxWidth) {
            swiper1.setWrapperTranslate(maxTranslate);
        } else {
            var translate = slideCenter - swiperHalf;
            swiper1.setWrapperTranslate(-translate);
        }
        
        swiper2.slideTo(swiper1.clickedIndex);
    })
    
    var swiper2 = new Swiper('.tab-cont', {
        onSlideChangeStart: function(swiper){
            swiper1.clickedIndex = swiper.activeIndex;
            swiper1.slides.eq(swiper.activeIndex).trigger('click');
            
          
        }

    })
    
    var mySwiper = new Swiper ('.lunbo .swiper-container', {
	    direction: 'horizontal',
	    autoplay:1000,
	    loop: true,
	    observer: true, //修改swiper自己或子元素时，自动初始化swiper 
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
	    
	    
	    // 如果需要分页器
	    pagination: '.swiper-pagination',
	    
	   
	})     
    
    
    

    $(".footer ._faxian").on("click",function(){
    	location.href="../html/find.html"
    })
    $(".footer ._shangdian").on("click",function(){
    	location.href="../html/shop.html"
    })
    $(".footer ._wode").on("click",function(){
    	location.href="../html/mine.html"
    })
    
});
